package com.wxit.gulimall.skill.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author wj
 * @date 2022.07.09 18:48
 *
 */
@Slf4j
@Component
//@EnableAsync
//@EnableScheduling
public class HelloSchedule {

    /**
     *
     * 1.可以让业务运行以异步的方式，自己提交到线程池
     * 2.支持定时任务线程池
     * 3.让定时任务异步执行
     */
    @Async
    @Scheduled(cron = "* * * * * ?")
    public void hello() throws InterruptedException {
        log.info("hello-----");
        Thread.sleep(3000);
    }
}
